<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>管理后台</title>
    <style>
        table {
            table-layout: fixed;
            border-spacing: 0;
            border-collapse: collapse;
        }
        td {
            padding: 4px;
            text-align: center;
        }
    </style>
    <#include "../styleandscript.ftl"/>
</head>
<body>
<#include "../header.ftl"/>
<div>
    <div style="margin-top: 16px; margin-bottom: 16px;">
        <#if userManager??>
            <span>用户管理</span> |
        <#else>
            <span><a href="/admin/user/list/1">用户管理</a></span> |
        </#if>
        <#if blogManager??>
            <span>文章管理</span>
        <#else>
            <span><a href="/admin/blog/list/1">文章管理</a></span>
        </#if>
    </div>
    <div>
    <#--用户管理-->
        <#if userManager??&&userPageInfo??>
        <#--用户搜索-->
            <div style="margin: 16px;text-align: center">
                <form action="/admin/user/list/1" method="get">
                    <input placeholder="关键字搜索" name="kw" class="form-control"
                           <#if kw??> value="${kw}" </#if>
                           style="width: auto;display: inline;"/>
                    <input type="submit" class="btn btn-primary" value="搜索"/>
                </form>
            </div>
        <#--用户列表-->
            <table border="1px" width="100%">
                <tr bgcolor="#d0d8df">
                    <td width="50px">ID</td>
                    <td width="150px">账号</td>
                    <td width="150px">邮箱</td>
                    <td width="200px">注册时间</td>
                    <td width="150px">操作</td>
                </tr>
                <#list userPageInfo.list as u>
                    <tr<#if u?index%2!=0> bgcolor="#e0ffff" </#if>>
                        <td>${u.id}</td>
                        <td><a href="/user/center/${u.name}">${u.name}</a></td>
                        <td>${u.email!"未设置"}</td>
                        <td>${u.createTime?datetime}</td>
                        <td>
                        <#if u.isDisable()>
                            <a href="/admin/user/enable/${u.id}">启用</a>
                        <#else>
                            <a href="/admin/user/disable/${u.id}">禁用</a>
                        </#if>&nbsp;
                        <#if u.isLocked()>
                            <a href="/admin/user/unlock/${u.id}">解锁</a>
                        <#else>
                            <a href="/admin/user/lock/${u.id}">锁定</a>
                        </#if>
                        </td>
                    </tr>
                </#list>
            </table>
        <#--分页-->
            <div style="margin-top: 16px;">
                <#if userPageInfo.hasPreviousPage>
                    <a href="/admin/user/list/${userPageInfo.prePage}<#if kw??>?kw=${kw}</#if>">上一页</a>&nbsp;
                <#else>
                    上一页&nbsp;
                </#if>
                <#list 1..userPageInfo.pages as i>
                    <#if userPageInfo.pageNum==i>
                        ${i}&nbsp;
                    <#else>
                        <a href="/admin/user/list/${i}">${i}</a>&nbsp;
                    </#if>
                </#list>
                <#if userPageInfo.hasNextPage>
                    <a href="/admin/user/list/${userPageInfo.nextPage}<#if kw??>?kw=${kw}</#if>">下一页</a>
                <#else>
                    下一页
                </#if>
            </div>
        </#if>
    <#--文章管理-->
        <#if blogManager??&&blogPageInfo??>
        <#--文章搜索-->
            <div style="margin: 16px;text-align: center">
                <form action="/admin/blog/list/1" method="get">
                    <input placeholder="关键字搜索" name="kw" class="form-control"
                           <#if kw??> value="${kw}" </#if>
                           style="width: auto;display: inline;"/>
                    <input type="submit" class="btn btn-primary" value="搜索"/>
                </form>
            </div>
        <#--文章列表-->
            <table border="1px" width="100%">
                <tr bgcolor="#d0d8df">
                    <td width="50px">ID</td>
                    <td>标题</td>
                    <td width="100px">作者</td>
                    <td width="150px">发布时间</td>
                    <td width="150px">最后修改时间</td>
                    <td width="50px">操作</td>
                </tr>
                <#list blogPageInfo.list as blog>
                    <tr<#if blog?index%2!=0> bgcolor="#e0ffff" </#if>>
                        <td>${blog.id}</td>
                        <td><a href="/blog/detail/${blog.id}">${blog.title}</a></td>
                        <td>
                            <a href="/admin/blog/list/1?uid=${blog.author.id}">${blog.author.name}</a>
                        </td>
                        <td>${blog.createTime?datetime}</td>
                        <td>${blog.editTime?datetime}</td>
                        <td>
                            <#if blog.isDel()>
                                <a href="/admin/blog/undel/${blog.id}">撤销删除</a>
                            <#else>
                                <a href="/admin/blog/del/${blog.id}">删除</a>
                            </#if>&nbsp;
                        </td>
                    </tr>
                </#list>
            </table>
        <#--分页-->
            <div style="margin-top: 16px;">
                <#if blogPageInfo.hasPreviousPage>
                    <a href="/admin/blog/list/${blogPageInfo.prePage}<#if kw??||uid??>?</#if><#if kw??>kw=${kw}</#if><#if uid??>${uid}</#if>">上一页</a>&nbsp;
                <#else>
                    上一页&nbsp;
                </#if>
                <#list 1..blogPageInfo.pages as i>
                    <#if blogPageInfo.pageNum==i>
                        ${i}&nbsp;
                    <#else>
                        <a href="/admin/blog/list/${i}">${i}</a>&nbsp;
                    </#if>
                </#list>
                <#if blogPageInfo.hasNextPage>
                    <a href="/admin/blog/list/${blogPageInfo.nextPage}<#if kw??||uid??>?</#if><#if kw??>kw=${kw}</#if><#if uid??>${uid}</#if>">下一页</a>
                <#else>
                    下一页
                </#if>
            </div>
        </#if>
    </div>
</div>
</body>
</html>